﻿<UserControl x:Class="View.ResourceFileView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:diagnostics="clr-namespace:System.Diagnostics;assembly=WindowsBase"
  xmlns:vw="clr-namespace:DotNetNuke.Translator.View"
  xmlns:cm="clr-namespace:DotNetNuke.Translator.Common"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
 <UserControl.InputBindings>
  <KeyBinding
   Key="A"
   Modifiers="Control"
   Command="{Binding Path=SelectAllCommand}"
   />
  <KeyBinding
   Key="S"
   Modifiers="Control"
   Command="{Binding Path=SaveCommand}"
   />
  <KeyBinding
   Key="W"
   Modifiers="Control"
   Command="{Binding Path=CloseCommand}"
   />
 </UserControl.InputBindings>
 <UserControl.Resources>
  <cm:BoolToVisibilityConverter x:Key="BoolToVisConverter" />
 </UserControl.Resources>
 <Grid>
  <Grid.ColumnDefinitions>
   <ColumnDefinition Width="Auto" />
   <ColumnDefinition Width="*"/>
  </Grid.ColumnDefinitions>
  <Grid.RowDefinitions>
   <RowDefinition Height="Auto" />
   <RowDefinition Height="*" />
  </Grid.RowDefinitions>
  <DataGrid x:Name="ResourcesGrid" Grid.Row="1" Grid.Column="1" HorizontalAlignment="Left"
      Margin="0,6,6,6" VerticalAlignment="Top" 
      CanUserResizeRows="False"
      AutoGenerateColumns="false"
      ItemsSource="{Binding Path=ResourceKeys}" EnableRowVirtualization="False">
   <DataGrid.Resources>
    <cm:BindingProxy x:Key="Proxy" Data="{Binding}" />
   </DataGrid.Resources>
   <DataGrid.Columns>
    <DataGridTemplateColumn Header="File" Width="SizeToCells" IsReadOnly="True" SortMemberPath="ResourceFile"
     Visibility="{Binding Data.ShowFileColumn, Source={StaticResource Proxy}, Converter={StaticResource BoolToVisConverter}}">
     <DataGridTemplateColumn.CellTemplate>
      <DataTemplate>
       <TextBlock Text="{Binding ResourceFile}" />
      </DataTemplate>
     </DataGridTemplateColumn.CellTemplate>
    </DataGridTemplateColumn>
    <DataGridTemplateColumn Header="Key" Width="SizeToCells" IsReadOnly="True" SortMemberPath="Key">
     <DataGridTemplateColumn.CellTemplate>
      <DataTemplate>
       <TextBlock Text="{Binding Key}" />
      </DataTemplate>
     </DataGridTemplateColumn.CellTemplate>
    </DataGridTemplateColumn>
    <DataGridTemplateColumn Header="Original Value" Width="*" IsReadOnly="True" SortMemberPath="OriginalValue">
     <DataGridTemplateColumn.CellTemplate>
      <DataTemplate>
       <TextBox Text="{Binding OriginalValue, Mode=OneWay}" TextWrapping="Wrap" IsReadOnly="True" />
      </DataTemplate>
     </DataGridTemplateColumn.CellTemplate>
    </DataGridTemplateColumn>
    <DataGridTemplateColumn
     Width="*" IsReadOnly="False" SortMemberPath="TargetValue"
     Header="{Binding Data.TargetColumnHeader, Source={StaticResource Proxy}}"
     Visibility="{Binding Data.ShowTargetColumn, Source={StaticResource Proxy}, Converter={StaticResource BoolToVisConverter}}">
     <DataGridTemplateColumn.CellTemplate>
      <DataTemplate>
       <TextBox Text="{Binding TargetValue, UpdateSourceTrigger=PropertyChanged}" 
                TextWrapping="Wrap" 
                AcceptsReturn="True"
                Background="{Binding TargetColor, UpdateSourceTrigger=PropertyChanged}"
                x:Name="txtTarget"
                >
       </TextBox>
      </DataTemplate>
     </DataGridTemplateColumn.CellTemplate>
    </DataGridTemplateColumn>
    <DataGridTemplateColumn
     Width="*" IsReadOnly="True" SortMemberPath="CompareValue"
     Header="{Binding Data.CompareColumnHeader, Source={StaticResource Proxy}}"
     Visibility="{Binding Data.ShowCompareColumn, Source={StaticResource Proxy}, Converter={StaticResource BoolToVisConverter}}">
     <DataGridTemplateColumn.CellTemplate>
      <DataTemplate>
       <TextBox Text="{Binding CompareValue, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}" TextWrapping="Wrap" Background="{Binding CompareColor, UpdateSourceTrigger=PropertyChanged}" />
      </DataTemplate>
     </DataGridTemplateColumn.CellTemplate>
    </DataGridTemplateColumn>
   </DataGrid.Columns>
   <DataGrid.RowStyle>
    <Style>
     <Setter Property="DataGridRow.IsSelected" Value="{Binding Selected, Mode=TwoWay}" />
    </Style>
   </DataGrid.RowStyle>
  </DataGrid>
 </Grid>
</UserControl>
